doctype
html
    head
        meta(charset="utf-8")
        title #{title}
        link(href="/css/admin.css",rel="stylesheet")
        link(href='//cdn.bootcss.com/webuploader/0.1.1/webuploader.css', rel='stylesheet')
    body.sub-body
        .pos-rlt.p-md
            span 首页
            em >
            span 更新合作伙伴
        .p-md.m-top
            .panel.panel-default
                .panel-body
                    .tab_t
                        span.a.active 合作伙伴列表
                .pane-body.atricle-form
                    .form-group.m-h-n.clearfix
                        label.control-label 名称：
                        .col-sm-6
                            input.form-control(type="text",name="title",value="#{partners.title}")
                    .form-group.m-h-n.clearfix
                        label.control-label 排序：
                        .col-sm-5
                            input.form-control(name="sort",value="#{partners.sort}")
                    .form-group.m-h-n.clearfix
                        label.control-label 选择图片：
                        .col-sm-5
                            input#imgPath(type="hidden",name="imgPath",value="#{partners.imgPath}",data-id="#{partners._id}")
                            div.imgpath
                                img#updateImg.updateImg(src="#{partners.imgPath}")
                            #filePicker
                    .form-group.m-h-n.clearfix
                        label.control-label 介绍：
                        .col-sm-6
                            textarea.form-control(rows="5",name="subject") #{partners.subject}
                    .form-group.m-h-n.clearfix
                        label.control-label
                        .col-sm-6
                            .submit_type.t-l
                                button#submit.btn.btn-sm.btn-danger(type="submit") 提交
        script(src="http://cdn.bootcss.com/jquery/2.2.0/jquery.min.js",type="text/javascript")
        script(src='//cdn.bootcss.com/webuploader/0.1.1/webuploader.js')
        script(src="/js/adminBase.js",type="text/javascript")
        script(src='/js/h5webuploader.js')
        script.
            $(function () {
                $("#filePicker").uploads();
                var imgPath = $("#imgPath");
                $("#submit").on("click", function () {
                    var title = $("input[name='title']").val();
                    var sort = $("input[name='sort']").val();
                    var imgPathVal = imgPath.val();
                    var _id = imgPath.attr("data-id");
                    var subject = $("textarea[name='subject']").val();
                    if ($.isEmptyObject(title)) {
                        A.Msg("标题不能为空")
                        return;
                    }if ($.isEmptyObject(imgPath)) {
                        A.Msg("图片不能为空")
                        return;
                    } else if ($.isEmptyObject(subject)) {
                        A.Msg("介绍不能为空")
                        return;
                    }
                    var data = {
                        _id: _id,
                        title: title,
                        sort: sort,
                        imgPath: imgPathVal,
                        subject: subject
                    }
                    $.ajax({
                        url: '/admin/partnersSave',
                        type: 'POST',
                        data: data,
                        success: function (datas) {
                            if (datas.success) {
                                window.location.href = "/admin/partnersList";
                            }
                        }
                    });
                })
            })
